package com.wanxi.dangdang.model.vo;

import com.wanxi.dangdang.model.pojo.Admin;
import com.wanxi.dangdang.model.pojo.Role;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @Author: 吕永杰
 * @Description:
 * @Date: Created in 2021/8/31
 * @Version: 1.0
 */
@Data
@ApiModel(value = "com.wanxi.dangdang.model.pojo.AdminVo")
public class AdminVo extends Admin implements UserDetails {
    private Integer pageNum=0;
    private Integer pageSize=5;
    private List<Role> roles;
    //用户权限
    private Set<? extends GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getUsername() {
        return getAccount();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
